home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / DevTools / COWS / Fred / MyView.m < prev    next >
Encoding:
Text File  |  1995-06-12  |  2.4 KB  |  147 lines

  1. /*     
  2.  
  3.     Fred 
  4.  
  5.     Implementation
  6.  
  7.     Created:          November 1991
  8.     Last Edited:    March 1994
  9.     
  10.     Sean Luke
  11.     
  12. */
  13.  
  14.  
  15. #import "FredLibrary.h"
  16.  
  17.  
  18. @implementation FredLibrary
  19.  
  20. - init:sender
  21. {
  22.     thisWindow=[NXApp appIcon];
  23.     return [super init];
  24. }
  25.  
  26.  
  27. - loadLibraries:sender
  28.     {
  29.     id returnval=[super loadLibrary:sender];
  30.     
  31.     if (![sender conformsTo:@protocol(LibraryControl)])
  32.         {
  33.         printf ("Fred error:  Interpreter cannot accept Library Control protocol!\n");
  34.         return NULL;
  35.         }
  36.         
  37.         [sender addLibraryFunction:"icon-x"
  38.             selector:@selector(fred_iconXPosition:)
  39.             target:self];
  40.     
  41.         [sender addLibraryFunction:"icon-y"
  42.             selector:@selector(fred_iconYPosition:)
  43.             target:self];
  44.     
  45.         [sender addLibraryFunction:"mouse-x"
  46.             selector:@selector(fred_mouseXPosition:)
  47.             target:self];
  48.     
  49.         [sender addLibraryFunction:"mouse-y"
  50.             selector:@selector(fred_mouseYPosition:)
  51.             target:self];
  52.     
  53.         [sender addLibraryFunction:"move-icon"
  54.             selector:@selector(fred_moveIcon:)
  55.             target:self];
  56.     
  57.     return self;
  58.     }
  59.     
  60. - pauseCancelled:sender
  61.     {
  62.     return self;
  63.     }
  64.  
  65. - fred_iconXPosition:arg_list
  66.     {
  67.     id returnval=[[COWSStringNode alloc] init];
  68.     char buf[COWSLARGENUMBER];
  69.     NXRect rect;
  70.     
  71.     [theWindow getFrame:&rect];
  72.     sprintf(buf,"%f",rect.origin.x);
  73.     [returnval setString:buf];
  74.     return returnval;
  75.     }
  76.  
  77.  
  78. - fred_iconYPosition:arg_list
  79.     {
  80.     id returnval=[[COWSStringNode alloc] init];
  81.     char buf[COWSLARGENUMBER];
  82.     NXRect rect;
  83.     
  84.     [theWindow getFrame:&rect];
  85.     sprintf(buf,"%f",rect.origin.y);
  86.     [returnval setString:buf];
  87.     return returnval;
  88.     }
  89.  
  90.  
  91. - fred_mouseXPosition:arg_list
  92.     {
  93.     id returnval=[[COWSStringNode alloc] init];
  94.     char buf[COWSLARGENUMBER];
  95.     NXPoint point;
  96.     
  97.     [theWindow getMouseLocation:&point];
  98.     sprintf(buf,"%f",point.x);
  99.     [returnval setString:buf];
  100.     return returnval;
  101.     }
  102.     
  103.  
  104. - fred_mouseYPosition:arg_list
  105.     {
  106.     id returnval=[[COWSStringNode alloc] init];
  107.     char buf[COWSLARGENUMBER];
  108.     NXPoint point;
  109.     
  110.     [theWindow getMouseLocation:&point];
  111.     sprintf(buf,"%f",point.y);
  112.     [returnval setString:buf];
  113.     return returnval;
  114.     }
  115.  
  116.  
  117. - fred_moveIcon:arg_list
  118.     {
  119.     id returnval=[[COWSStringNode alloc] init];
  120.     id item,value;
  121.     
  122.     if ([arg_list top]==NULL)                 // no args
  123.         {
  124.         [returnval setString:"f"];
  125.         return returnval;
  126.         }
  127.     
  128.     item=[arg_list pop];
  129.     
  130.     if ([arg_list top]==NULL)                 // just one arg
  131.         {
  132.         [returnval setString:"f"];
  133.         [item free];
  134.         return returnval;
  135.         }
  136.  
  137.     value=[arg_list pop]; 
  138.     
  139.     [theWindow moveTo:atof([item string]):atof([value string])];
  140.     [item free];
  141.     [value free];
  142.     
  143.     [returnval setString:"t"];
  144.     return returnval;
  145.     }
  146.  
  147. @end